package com.minglead.springboot.platform.sys.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.minglead.springboot.common.crud.CrudService;
import com.minglead.springboot.platform.sys.dao.OfficeDao;
import com.minglead.springboot.platform.sys.dao.RoleDao;
import com.minglead.springboot.platform.sys.entity.Role;


/**
 * 角色Service
 */
@Service
@Transactional(readOnly = true)
public class RoleService extends CrudService<RoleDao, Role> {
	@Autowired
	private OfficeDao officeDao;
	@Autowired
	private AreaService areaService;

	@Autowired
	private RoleDao roleDao;
	
	public void wrapEntity(Role entity) {
		entity.setDataScopeValue(Role.getDataScopeLabel(entity.getDataScope()));
	}

    /**
     * 角色删除，同时删除角色用户关联信息
     * @param temp
     */
	@Transactional(readOnly = false)
	public void deleteEntity(String id) {
		Role temp = new Role();
		temp.setId(id);
		roleDao.delete(temp);
		//删除角色用户关联
/*		roleDao.deleteRoleOffice(temp);*/
		roleDao.deleteUserRole(temp);
	}
	
}
